/**
 * API响应通用类型
 * 与后端的ApiResponse保持一致
 */
export interface ApiResponse<T = any> {
  success: boolean;
  message: string;
  data: T | null;
}

/**
 * API请求类型
 */
export interface ApiRequest<T = any> {
  params?: Record<string, any>;
  data?: T;
  headers?: Record<string, string>;
}

/**
 * API分页参数
 */
export interface PaginationParams {
  page: number;
  pageSize: number;
}

/**
 * API分页响应
 */
export interface PaginatedResponse<T> {
  items: T[];
  totalCount: number;
  currentPage: number;
  pageSize: number;
  totalPages: number;
}

/**
 * 认证相关类型
 */
export interface AdminUser {
  _id: string;
  username: string;
  displayName: string;
  role: string;
  email: string;
  createdAt: number;
  lastLoginAt: number | null;
  enabled: boolean;
}

export interface UserData {
  username: string;
  status: 'active' | 'inactive' | 'locked';

  displayName: string;
  role: string;
  email: string;
  createdAt: number;
  lastLoginAt: number | null;
  enabled: boolean;
  permissions?: string[];
}

/**
 * 登录请求
 */
export interface LoginRequest {
  username: string;
  password: string;
}

/**
 * 登录响应
 */
export interface AuthResponse {
  user?: UserData;
  token?: string;
  refreshToken?: string;
  expiresIn?: number;
}

/**
 * 刷新令牌请求
 */
export interface RefreshTokenRequest {
  refreshToken: string;
}

/**
 * 刷新令牌响应
 */
export interface RefreshTokenResponse {
  token: string;
  refreshToken: string;
  expiresIn: number;
}

/**
 * 用户管理相关类型
 */
export interface CreateUserRequest {
  username: string;
  password: string;
  displayName: string;
  role: string;
  email?: string;
}

export interface UpdateUserRequest {
  displayName?: string;
  email?: string;
  role?: string;
  password?: string | null;
  enabled?: boolean;
}

export interface UsersListResponse {
  users: UserData[];
  totalCount: number;
  currentPage: number;
  pageSize: number;
  totalPages: number;
}

/**
 * 批量操作相关类型
 */
export interface BulkDeleteRequest {
  ids: string[];
}

export interface BulkUpdateStatusRequest {
  ids: string[];
  status: string;
}

export interface BulkActionResponse {
  deletedCount?: number;
  updatedCount?: number;
} 